{	Problem: http://codeforces.ru/problemset/problem/102/A
	Verdict: Accepted
}
uses
    Math;

const
    infinity:longint = maxlongint;

var
    n,m,i,j,k,ans,x,y:longint;
    a:array[0..110] of longint;
    b:array[0..110,0..110] of boolean;  

begin
fillchar(b,sizeof(b),0);
read(n,m);
for i:=1 to n do
    read(A[i]);
for i:=1 to m do begin
    read(x,y);
    b[x][y]:=true;
    b[y][x]:=true;
end;
ans:=infinity;
for i:=1 to n do
    for j:=1 to n do
        for k:=1 to n do
            if (i<>j) and (j<>k) and (i<>k) then
                if b[i][j] and b[i][k] and b[j][k] then ans:=min(ans,a[i]+a[j]+a[k]);
if ans = infinity then write(-1) else write(ans);
end.